Skip to content

Upgraded to MEDS v0.4#181

Merged
justin13601 merged 1 commit intomainfrom
180_MEDS_v04
May 6, 2025
Merged

Upgraded to MEDS v0.4#181
justin13601 merged 1 commit intomainfrom
180_MEDS_v04

Conversation

@mmcdermott
Copy link
Collaborator

@mmcdermott mmcdermott commented May 6, 2025

Closes #180. Will require a major release to incorporate.

Summary by CodeRabbit

  • Refactor
    • Updated internal references to schema field names to use centralized schema classes, improving consistency across the application.
  • Chores
    • Broadened the acceptable version range for a key dependency, enhancing compatibility with future releases.
  • Tests
    • Adjusted test code to utilize schema classes for field names, reducing reliance on hardcoded strings.

@mmcdermott mmcdermott requested review from Copilot and justin13601 May 6, 2025 16:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

The changes update the codebase to use the new LabelSchema class from the meds package for all label schema references, replacing scattered constants and string literals. The dependency on meds is updated to allow versions compatible with 0.4.0. Test code is refactored to use centralized schema classes.

Changes

File(s) Change Summary
pyproject.toml Updated meds dependency from ==0.3.3 to ~=0.4.0.
src/aces/run.py Replaced direct constant imports with LabelSchema class; updated all label schema references; used LabelSchema.align() for schema alignment.
tests/test_meds.py Replaced string constants and field names with DataSchema and LabelSchema class attributes; refactored test data and schema alignment logic.

Sequence Diagram(s)

sequenceDiagram
    participant ACES_Run
    participant MEDS_LabelSchema

    ACES_Run->>MEDS_LabelSchema: Import LabelSchema
    ACES_Run->>MEDS_LabelSchema: Use LabelSchema attributes for schema validation
    ACES_Run->>MEDS_LabelSchema: Call LabelSchema.align(df)
    MEDS_LabelSchema-->>ACES_Run: Return aligned DataFrame/Table
Loading

Assessment against linked issues

Objective Addressed Explanation
Upgrade to MEDS v0.4 (#180)

Possibly related PRs

Suggested labels

Impacts Benchmark

Suggested reviewers

  • justin13601

Poem

In fields of code where schemas grow,
The LabelSchema now steals the show.
No more strings that roam or stray,
All fields aligned the MEDS way.
With tests and benchmarks hopping right,
This bunny’s code is clean and bright!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58dd44d and c802d98.

📒 Files selected for processing (3)
  • pyproject.toml (1 hunks)
  • src/aces/run.py (8 hunks)
  • tests/test_meds.py (9 hunks)
🔇 Additional comments (16)
pyproject.toml (1)

29-29: Update confirmed for MEDS package dependency.

The dependency specification for meds has been appropriately updated to use the compatible release operator ~=, allowing any version from 0.4.0 up to (but not including) 0.5.0. This change aligns with the project's upgrade to MEDS version 0.4.

src/aces/run.py (9)

14-14: Updated import to use centralized schema classes.

Replacing individual constant imports with the LabelSchema class is a good approach for centralizing schema references.


23-24: Schema constants now use LabelSchema reference.

Using LabelSchema.subject_id_name provides a more maintainable and centralized approach for schema references.


27-32: Schema constants migrated to LabelSchema references.

All optional type references have been updated to use the appropriate LabelSchema attributes, making the code more maintainable.


71-72: Type correction in docstring example.

The type for float_value was correctly changed from double to float in the example docstring to match the actual output.


83-84: Updated schema validation to use LabelSchema.

References to prediction time field now use the centralized LabelSchema.prediction_time_name attribute.


95-95: Updated error message to reference Label DataFrame.

Error message now correctly refers to "MEDS Label DataFrame" instead of "MEDS Data DataFrame".


118-118: Simplified schema alignment using LabelSchema.align.

The previous manual conversion and casting has been replaced with a cleaner call to LabelSchema.align(), leveraging the functionality provided by the updated MEDS package.


148-153: Updated column mapping to use LabelSchema references.

The column name mappings in the rename operation now use the centralized LabelSchema attributes instead of hardcoded strings.


154-159: Updated subject_id check using LabelSchema reference.

The check for the existence of the subject_id column and the creation of an empty column now use the LabelSchema.subject_id_name attribute.

tests/test_meds.py (6)

10-10: Updated import to use centralized schema classes.

Importing both DataSchema and LabelSchema from meds for centralizing schema references in tests.


39-43: MEDS_PL_SCHEMA now uses DataSchema references.

Schema field definitions now use DataSchema attributes instead of hardcoded string constants.


47-56: Label schema types now use LabelSchema references.

Both mandatory and optional label schema type definitions now use LabelSchema attributes.


115-115: Simplified schema alignment using LabelSchema.align.

Similar to the change in run.py, the function now uses LabelSchema.align() to handle alignment.


133-133: Updated time column reference using DataSchema.

Time column access now uses DataSchema.time_name instead of a hardcoded string.


162-359: Updated test data to use standard schema column names.

All test YAML strings have been updated to use standard schema column names without variable interpolation, which is more maintainable.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the MEDS dependency to v0.4 and refactors the code to use the new DataSchema and LabelSchema naming conventions. Key changes include:

  • Updating test imports and schema definitions in tests/test_meds.py to use DataSchema and LabelSchema.
  • Refactoring schema references, error messages, and column renames in src/aces/run.py.
  • Adjusting the MEDS dependency version in pyproject.toml.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_meds.py Updated import statements and schema usage to align with MEDS v0.4.
src/aces/run.py Refactored schema references and error messages for consistency.
pyproject.toml Updated MEDS dependency version to ~0.4.0.
Comments suppressed due to low confidence (1)

src/aces/run.py:71

  • Verify that changing the cast from 'double' to 'float' for the 'float_value' field aligns with the MEDS v0.4 specification and does not introduce precision issues.
float_value: float

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/aces/run.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@justin13601 justin13601 merged commit 3985f8d into main May 6, 2025
8 checks passed
@justin13601 justin13601 deleted the 180_MEDS_v04 branch May 6, 2025 19:06
@coderabbitai coderabbitai bot mentioned this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to MEDS v0.4

3 participants